package com.szh.cloud.api.role.service.impl;

import com.szh.cloud.api.role.repository.ApiRoleDao;
import com.szh.cloud.api.role.service.ApiRoleService;
import com.szh.cloud.mybatis.entity.PtRoleEntity;
import com.szh.cloud.mybatis.etable.ElTable;
import com.szh.cloud.mybatis.flexigrid.PagingBean;
import com.szh.cloud.role.entity.SearchRoleEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ApiRoleServiceImpl implements ApiRoleService {
    @Resource
    private ApiRoleDao apiRoleDao;

    @Override
    public ElTable<PtRoleEntity> queryRoleListByPage(SearchRoleEntity entity, PagingBean paging) {
        paging.deal(PtRoleEntity.class);
        ElTable<PtRoleEntity> entityElTable = new ElTable<>();
        Integer total = apiRoleDao.queryRoleTotal(entity);
        entityElTable.setTotal(total);
        Integer page = paging.getPage(total);
        entityElTable.setPage(page);

        List<PtRoleEntity> ptRoleEntityList = apiRoleDao.queryRoleListByPage(entity,paging);
        entityElTable.setRawRecords(ptRoleEntityList);
        return entityElTable;
    }
}
